package hawk.example.jdk.io;

import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;

public class FileSystemTest {

    public static void main(String[] args) throws IOException {
        String zipFileName = "data/archive.zip";
        listAllInZipFile(zipFileName);
    }

    private static void listAllInZipFile(String zipFileName) throws IOException {
        FileSystem fs = FileSystems.newFileSystem(Path.of(zipFileName));
        Files.walkFileTree(fs.getPath("/"), new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                System.out.println(file);
                return FileVisitResult.CONTINUE;
            }
        });
    }
}
